//11.盛最多水的容器
//先算容积->移动指针->算容积-->比较容积大小，再进行上述重复操作
//时间复杂度O(N)  空间复杂度O(1)
class Solution {
    public int maxArea(int[] height) {
        int left = 0;
        int right = height.length-1;
        int ret = 0;
        while(left < right){
            int h = Math.min(height[left],height[right]);
            int w = right - left;
            int v = h * w;
            ret = Math.max(ret,v);//更新最大容积
            if(height[left] < height[right]){
                left++;
            }else{
                right--;
            }
        }
        return ret;
    }
}